<%@page import="com.neuedu.my12306.entity.UserInfo"%>
<%@page import="java.util.List"%>
<%@page import="com.neuedu.my12306.util.UserinfoUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>所有用户管理</title>
<link href="<%=request.getContextPath()%>/css/css.css" rel="stylesheet" type="text/css">
<script language="javascript">
	function UserAdd(){
		window.navigate("UserInfo_Add.html");
	
	}
</script>

<script>
function selectAllNullorReserve(obj,type){
   if(obj!=null&&obj!=""){
    if(document.getElementsByName(obj)!=undefined&&document.getElementsByName(obj).length>0){	//getElementsByName函数的作用按名字查找对象，返回一个数组。
     var userids = document.getElementsByName(obj);
     if(type=="全选"){
      for(var i=0;i<userids.length;i++){
       if(userids[i].checked == false){
        userids[i].checked = true;
       }
      }
     }else if(type=="全不选"){
      for(var i=0;i<userids.length;i++){
       if(userids[i].checked == true){
        userids[i].checked = false;
       }
      }
     }else if(type=="反选"){
      for(var i=0;i<userids.length;i++){
       if(userids[i].checked == true){
        userids[i].checked = false;
       }else{
        userids[i].checked = true;
       }
      }
     }
    }
   }  
}
function changePage(p){
	//使用JavaScript进行dom解析
	var s = document.getElementById("pageSize").value;
	//alert(s);
	//使用JavaScript把分页参数传递回服务器
	location.href="<%=request.getContextPath()%>/UserAdminServlet.do?page="+p+"&size="+s;
}
 function deleteUser(){
	 var form = document.UserForm;
	 form.action="<%=request.getContextPath()%>/UserDeleteServlet.do";
	 var userids = form.userName;
	 var flag = false;
	 for(var i=0; i< userids.length; i++){
		 if(userids[i].checked == true){
			 flag = true;
			 break;
		 }
	 }
	 if(flag){
		 if(confirm("是否删除？")){
			 form.submit();
		 }
		
	 }else{
		 alert("请选择需要删除的用户! ");
	 }
 }
</script>
</head>
<body class="write_bg">
 <form name="UserForm" method="post" action="">

<table width="1107" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"></td>
  </tr>
</table>
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="20" colspan="2" ></td>
  </tr>
  <tr>
    <td width="13" height="30" align="left" valign="top"  ></td>
    <td width="822" align="left" valign="top"  class="text_blod_title">用户管理</td>
  </tr>
  <tr>
    <td height="15" colspan="2" align="center" ><img src="<%=request.getContextPath()%>/images/line.jpg" width="850" height="6"></td>
  </tr>
  <tr>
    <td height="15" colspan="2"  ></td>
  </tr>
</table>
<table width="835" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="835" background="<%=request.getContextPath()%>/images/wb_01 (3).jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="5"></td>
        <td width="4%" height="25" align="left" class="text_cray1">姓名</td>
        <td width="11%" align="left" class="text_cray1"><label>
          <input name="textfield" type="text" class="text_cray" style="width:80px">
        </label></td>
        <td width="6%" align="center" class="text_cray1">性别</td>
        <td width="6%" align="left" class="text_cray1"><label>
          <select name="select" class="text_cray">
            <option value="N">男</option>
            <option value="M">女</option>
          </select>
        </label></td>
        <td width="9%" align="center" class="text_cray1">证件类型</td>
        <td width="13%" align="left" class="text_cray1"><label>
          <select class="text_cray" name="loginUserDTO.id_type_code" id="cardType">
            <option value="1">二代身份证</option>
            <option value="C">港澳通行证 </option>
            <option value="G">台湾通行证</option>
            <option value="B">护照</option>
          </select>
        </label></td>
        <td width="8%" align="center" class="text_cray1">证件号码</td>
        <td width="13%" align="left" class="text_cray1"><label>
          <input name="textfield2" type="text" class="text_cray" style="width:100px">
        </label></td>
        <td width="8%" align="center" class="text_cray1">旅客类型</td>
        <td width="13%" align="left" class="text_blod"><label>
          <select class="text_cray" id="passengerType" name="passenger_type" style="width:100px">
            <option value="1">成人</option>
            <option value="2">儿童</option>
            <option value="3">学生</option>
            <option value="4">残疾军人、伤残人民警察</option>
          </select>
        </label></td>
        <td width="8%" align="center" valign="middle" class="text_craybold"><label>
          <input name="Submit" type="submit" class="butcx" value="">
        </label></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td height="20" colspan="11" align="center">&nbsp;</td>
      </tr>
    </table>
        <table width="553" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#dadada" bgcolor="#FFFFFF">
          <tr align="center">
            <td width="44" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"   class="text_cray1">选择</td>
            <td width="98" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">姓名</td>
            <td width="80" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">性别</td>
            <td width="132" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">证件类型</td>
            <td width="247" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">证件号码</td>
            <td width="82" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">旅客类型</td>
            <td width="89" height="25" valign="middle" bordercolor="#FFFFFF" bgcolor="#FFFFFF"  class="text_cray1">操作</td>
          </tr>
          <tr align="center">
            <td height="15" colspan="7" bordercolor="#FFFFFF" bgcolor="#FFFFFF"   class="text_cray1"><img src="<%=request.getContextPath()%>/images/line1.jpg" width="790" height="6"></td>
          </tr>
           <!-- 循环迭代start  userInfoList -->
           <!-- 循环迭代标签，items用于设置要循环的数组，集合等等，var 用于保存循环得到的每一个数据 -->
           <c:forEach items="${userInfoList}" var="userInfo" varStatus="userStatus">
           		<c:if test="${userStatus.index %2==0}">
          			<tr align=center bgcolor=#FFFFFF>
          		</c:if>
          		<c:if test="${userStatus.index %2==1}">
          			<tr align=center bgcolor=#F5F5F5>
          		</c:if>
						<td bordercolor="#FFFFFF" class="text_cray1"><input type="checkbox" name="userName" value="${userInfo.userName}"></td>
						<td width="98" bordercolor="#FFFFFF" class="text_cray1">${userInfo.userName}</td>
						<td width="80" bordercolor="#FFFFFF" class="text_cray1">${userInfo.sex eq 'M'?'男':'女'}</td>
						<!-- el表达式支持三元运算符号，三元运算符号支持嵌套 -->
						<td width="132" bordercolor="#FFFFFF" class="text_cray1">
						${userInfo.cardType eq '1'?'二代身份证':(userInfo.cardType eq 'C'?'港澳通行证':(userInfo.cardType eq 'G'?'台湾通行证':'护照'))}
						</td>
						<td width="247" bordercolor="#FFFFFF" class="text_cray1">${userInfo.idNumber==null?'无':userInfo.idNumber}</td>
						<td width="82" bordercolor="#FFFFFF" class="text_cray1">
						${userInfo.passengerType eq '1'?'成人':(userInfo.passengerType eq '2'?'儿童':(userInfo.passengerType eq '3'?'学生':'残疾军人、伤残人民警察'))}
						</td>
						<td width="89" bordercolor="#FFFFFF" class="text_cray1"><a
							href="<%=request.getContextPath()%>/ToEditUserServlet.do?uname=${userInfo.userName}"
							class="text_red">编辑</a></td>
					</tr>
			</c:forEach>
			<!-- 循环迭代end  userInfoList -->				
        </table>
      <br>
        <table width="773" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr align="center">
            <td width="102" align="left"  class="text_cray1"><a href="#">
              <label></label>
              <label></label>
              <label>
              <input type="checkbox" name="checkbox2" value="11"  onclick="selectAllNullorReserve('userName','反选');" ><span class="text_blue">全选</span></label>
            </a></td>
            <td width="525" align="right"  class="text_cray1"><a href="#">
              <!--<input type="button" name="Submit23" value="新增" onClick="UserAdd()"> -->
            </a></td>
            <td width="55" align="right"  class="text_cray1"><a href="#">
              <input name="Submit22"  onclick="deleteUser()" type="button" class="butsc" value="">
            </a></td>
            <td width="91" align="right"  class="text_cray1"><label>
              <input name="Submit3" type="submit" class="butdc" value="">
            </label></td>
          </tr>
        </table>
      <br>
        <table width="773" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr align="center" style="width:60%">
            <td width="335" align="center"  class="text_cray">&nbsp;</td>
            <td width="284" align="center"  class="text_cray">>> 
            <%
            Integer pages = (Integer)request.getAttribute("pages");
          	Integer prePage = (Integer)request.getAttribute("prePage");
          	Integer nextPage = (Integer)request.getAttribute("nextPage");
          	Integer size = (Integer)request.getAttribute("size");
          	if(pages!=null){
          		for(int i=1;i<=pages;i++){
          			out.print("<a href='javascript:changePage("+i+")'>"+i+"</a>  ");
          		}
          	}
            
            
            
            %>
            
             &lt;&lt; </td>
            <td width="154" align="right"  class="text_cray1" style="width:20%"><label class="text_cray"> 每页显示
                <select id="pageSize" name="size">
                    <option <%=size==3? "selected":"" %> value="3">3</option>
                    <option <%=size==6? "selected":"" %> value="6">6</option>
                    <option <%=size==9? "selected":"" %> value="9">9</option>
                  </select>
            条信息</label></td>
          </tr>
        </table>
      <br></td>
  </tr>
  <tr>
    <td height="20"></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0">
  <tr>
    <td height="2" background="<%=request.getContextPath()%>/images/bottom_point.gif"></td>
  </tr>
  <tr>
    <td height="25" align="center" background="<%=request.getContextPath()%>/images/bottom_ny_bg.gif" class="text_cray">copyright@12306 购票网</td>
  </tr>
</table>
</form>
</body>
</html>
